﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GestionePolveriLib.BL;

namespace GestionePolveri2.Editors
{
    public partial class DettaglioControlBase : UserControl, IDettaglio
    {
        public event EventHandler LoadData;

        private bool m_isClosable = true;
        private int m_causale;
        private OperatorePrincipal m_principal = null;
        private DateTime m_datareg;
        //private Double quant_old;
        //private int idPolvere_old = 0;

        //private string m_numfatt = null;
        //private long m_idlotto = 0;
        //private Double m_giacenzaFinale;
        //private Double m_giacenza_iniziale;
        private Movimento m_movimento = null;

        public Movimento Movimento
        {
            get { return m_movimento; }
            set { m_movimento = value; }
        }

        public OperatorePrincipal Principal
        {
            get { return m_principal; }
            set { m_principal = value; }
        }

        public bool IsClosable
        {
            get { return m_isClosable; }
            set { m_isClosable = value; }
        }

        public DettaglioControlBase()
        {
            InitializeComponent();
        }

        public virtual bool Add() { return false; }

        public virtual bool Delete() { return false; }

        public virtual bool Modify() { return false; }

        public virtual void ClearControls() { }

        public virtual bool Validate(string op) { return false; }

        public virtual void InitializeControl() {}

        public virtual void SetMovimento() { }

        protected virtual void OnLoadData(EventArgs e)
        {
            EventHandler invoker = LoadData;

            if (invoker != null) invoker(this, e);
        }
       
        protected void SelectComboItem(ComboBox comboBox, string item)
        {
            comboBox.SelectedIndex = comboBox.FindString(item,-1);
        }
    }
}
